<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title></title>
	<script type="text/javascript" src="<%=basePath %>/bootstrap/js/jquery.js"></script>
	<script type="text/javascript" src="<%=basePath %>/bootstrap/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="<%=basePath %>/bootstrap/css/bootstrap.min.css" />
	<style type="text/css">
		body{
			background-image:url("<%=basePath%>/bootstrap/img/5.jpg");
			 background-attachment :local; 
			 background-size: cover;
		}
		.container{
			margin-left:50px;
		}
		.container .nav{
			margin-left:120px;
		}
		.span3{
			background-image:url("<%=basePath%>/bootstrap/img/5.jpg");
		}
		.container-fluid{
			margin-top:70px;
			margin-left:-20px;
		}
		#navleft{
			font-size:18px;
		}
		#aleft{
			color:black;
		}
		#aleft:hover{
			color:blue;
		}
		.pagerhader,.reqiredtable {
			background-image:url("<%=basePath%>/bootstrap/img/5.jpg");
			border-bottom: 1px solid #DADEE5;
			font-size: 18px;
			padding: 15px 30px;
			position: relative;
		}
		.othertable{
			border-bottom: 1px solid #DADEE5;
			font-size: 18px;
			padding: 15px 30px;
			position: relative;
		}
		.pagecontent .time {
			width: 50px;
		}
		td {
			padding: 0.8em;
		}
	</style>
</head>
<body>
	<!--导航-->
	  	   <div id="navbar-example" class="navbar navbar-fixed-top">
            <div class="navbar-inner">
             <div class="container" style="width: auto; height:10px">
                <a class="brand" href="#">CRM</a>
                <ul class="nav">
					<li class="">
						 <form id="searchForm" class="navbar-search pull-left" action="http://www.google.com.hk/search" method="get">
								<input type="text" id="search" class="search-query span5" name="q" autocomplete="off" placeholder="Google Search"/>
								<script>
									$(document).ready(function(){
										$("#search").keydown(function(){
											if(event.keyCode == 13) {
												$("searchForm").submit();
											}

										});

									});
								</script>
							</form>
					  </li>
					  <li class="">
						<a href="">用户名：${sessionScope.user.username }</a>
					  </li>
                  <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#menu1">
							账号&设置
							<b class="caret"></b>
						</a>
                    <ul class="dropdown-menu">
						  <li><a href="users.action">我的信息</a></li>
						  <li><a href="groups.action">小组成员</a></li>
						  <script type="text/javascript">
							$(document).ready(function(){
								$(".dropdown-toggle").dropdown();
							});
						 </script>
						</ul>
					</li>
					  <li class="">
						<a href="leave.action">安全退出</a>
					  </li>
                </ul>
              </div>
            </div>
          </div>
		  <script type="text/javascript">
			$(document).ready(function(){
				$(".dropdown-toggle").dropdown();
			});
		  </script>

		  <!--左遍的内容-->
		<div class="container-fluid">
		  <div class="row-fluid">
			<div class="span3" style="border: 1px solid #DADEE5;width:170px;height:240px;padding-top:20px;margin-left:40px;">
				<div id="left">
					<ul class="nav nav-list" id="navleft">
					  <li>
						<a href="findAllMessage.action" id="aleft">
						   <img src="<%=basePath%>/bootstrap/img/22.png"/>
							最新动态
						</a>
					  </li>
					  <li>
						<a href="contacts.action" id="aleft">
						 <img src="<%=basePath%>/bootstrap/img/18.png"/>
							联系人
						</a>
					  </li>
					  <li>
						<a href="task.action" id="aleft">
						  <img src="<%=basePath%>/bootstrap/img/20.png"/>
							日程安排
						</a>
					  </li>
					  <li>
						<a href="deal.action" id="aleft">
						 <img src="<%=basePath%>/bootstrap/img/19.png"/>
							业务机会
						</a>
					  </li>
					  <li class="search">
						<a href="search.action" id="aleft">
							<img src="<%=basePath%>/bootstrap/img/21.png"/>
							搜索
						</a>
						</li>
					</ul>
				</div>
			</div>
			<!--中心的内容-->
			<div class="span6" style="border:1px solid #D7D7D7;background-color:white;width:550px">
				<div class="pagebody">

					<div class="pagerhader">
						显示
					<form action="findcontacts.action" class="form-inline">
    					<input name="name" type="text" placeholder="用户名或公司名" value="${requestScope.name }"/>
  						<button class="btn" type="submit"><i class="icon-search"></i>搜索</button>
    				</form>
					</div>
					<div class="pagecontent">
						<table>
								<!--for循环-->
						<c:forEach items="${clist }" var="c">
							<c:if test="${c.view=='all'&&c.enable }">
							<tr style="border-bottom:1px solid grey">
								<td width="60px">
									<a href="deletecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/26.png"/></a>
									||
									<a href="updatecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/27.png"/></a>
								</td>
								<td width="30px">
									<c:if test="${c.name!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/18.png"/></span>
									</c:if>
									<c:if test="${c.name==null&&c.companyname!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/25.png"/></span>
									</c:if>
								</td>
								<!--根据不同的情况显示不同-->
								<td width="50%">
									
									<a href="addcontactsnote.action?id=${c.id }">${c.name }</a><br/>
									公司名称：<a href="addcontactsnote.action?id=${c.id }">${c.companyname }</a><br/>
										联系电话
										<c:forEach items="${c.telSet }" var="t">
										<c:if test="${t.tel !=null }">
											${t.tel }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										邮件地址：
										<c:forEach items="${c.mailSet }" var="m">
										<c:if test="${m.mail !=null }">
											${m.mail }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										网址：
										<c:forEach items="${c.websiteSet }" var="w">
										<a href="${w.website }">${w.website }</a>&nbsp;
									</c:forEach>
								</td>
							</tr>
							</c:if>
							<c:if test="${c.view.split(',')[0]=='me'&&c.view.split(',')[1]==sessionScope.user.id&&c.enable }">
							<tr style="border-bottom:1px solid grey">
								<td width="60px">
									<a href="deletecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/26.png"/></a>
									||
									<a href="updatecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/27.png"/></a>
								</td>
								<td width="30px">
									<c:if test="${c.name!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/18.png"/></span>
									</c:if>
									<c:if test="${c.name==null&&c.companyname!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/25.png"/></span>
									</c:if>
								</td>
								<!--根据不同的情况显示不同-->
								<td width="50%">
									
									<a href="addcontactsnote.action?id=${c.id }">${c.name }</a><br/>
									公司名称：<a href="addcontactsnote.action?id=${c.id }">${c.companyname }</a><br/>
										联系电话
										<c:forEach items="${c.telSet }" var="t">
										<c:if test="${t.tel !=null }">
											${t.tel }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										邮件地址：
										<c:forEach items="${c.mailSet }" var="m">
										<c:if test="${m.mail !=null }">
											${m.mail }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										网址：
										<c:forEach items="${c.websiteSet }" var="w">
										<a href="${w.website }">${w.website }</a>&nbsp;
									</c:forEach>
								</td>
							</tr>
							</c:if>
							<c:if test="${c.view.split(',')[0]=='use'&&c.view.split(',')[1]==sessionScope.user.id&&c.enable  }">
							<tr style="border-bottom:1px solid grey" id="ux">
								<td width="60px">
									<a href="#" id="xx"><img src="<%=basePath %>/bootstrap/img/26.png"/></a>
									<%-- <a href="deletecontacts.action?id=${c.id }">del</a>
									||
									<a href="updatecontacts.action?id=${c.id }">edit</a> --%>
								</td>
								<td width="30px">
									<c:if test="${c.name!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/18.png"/></span>
									</c:if>
									<c:if test="${c.name==null&&c.companyname!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/25.png"/></span>
									</c:if> 
									
								</td>
								
								<!--根据不同的情况显示不同-->
								<td width="50%">
									
									<a href="addcontactsnote.action?id=${c.id }">${c.name }</a><br/>
									公司名称：<a href="addcontactsnote.action?id=${c.id }">${c.companyname }</a><br/>
										联系电话
										<c:forEach items="${c.telSet }" var="t">
										<c:if test="${t.tel !=null }">
											${t.tel }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										邮件地址：
										<c:forEach items="${c.mailSet }" var="m">
										<c:if test="${m.mail !=null }">
											${m.mail }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										网址：
										<c:forEach items="${c.websiteSet }" var="w">
										<a href="${w.website }">${w.website }</a>&nbsp;
									</c:forEach>
								</td>
							</tr>
							</c:if>
							<c:if test="${c.view.split(',')[0]=='group'&&c.view.split(',')[1]==sessionScope.user.usergroup.id&&c.enable  }">
							<tr style="border-bottom:1px solid grey" id="gx">
								<td width="60px">
									<a href="#" id="gxx"><img src="<%=basePath %>/bootstrap/img/26.png"/></a>
									<%-- ||
									<a href="updatecontacts.action?id=${c.id }">edit</a> --%>
								</td>
								<td width="30px">
									<c:if test="${c.name!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/18.png"/></span>
									</c:if>
									<c:if test="${c.name==null&&c.companyname!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/25.png"/></span>
									</c:if>
								</td>
								<!--根据不同的情况显示不同-->
								<td width="50%">
									
									<a href="addcontactsnote.action?id=${c.id }">${c.name }</a><br/>
									公司名称：<a href="addcontactsnote.action?id=${c.id }">${c.companyname }</a><br/>
										联系电话
										<c:forEach items="${c.telSet }" var="t">
										<c:if test="${t.tel !=null }">
											${t.tel }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										邮件地址：
										<c:forEach items="${c.mailSet }" var="m">
										<c:if test="${m.mail !=null }">
											${m.mail }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										网址：
										<c:forEach items="${c.websiteSet }" var="w">
										<a href="${w.website }">${w.website }</a>&nbsp;
									</c:forEach>
								</td>
							</tr>
							</c:if>
							<c:if test="${c.view.split(',')[0]=='group'&&c.user.id==sessionScope.user.id&&c.enable  }">
							<tr style="border-bottom:1px solid grey">
								<td width="60px">
									<a href="deletecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/26.png"/></a>
									||
									<a href="updatecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/27.png"/></a>
								</td>
								<td width="30px">
									<c:if test="${c.name!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/18.png"/></span>
									</c:if>
									<c:if test="${c.name==null&&c.companyname!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/25.png"/></span>
									</c:if>
								</td>
								<!--根据不同的情况显示不同-->
								<td width="50%">
									
									<a href="addcontactsnote.action?id=${c.id }">${c.name }</a><br/>
									公司名称：<a href="addcontactsnote.action?id=${c.id }">${c.companyname }</a><br/>
										联系电话
										<c:forEach items="${c.telSet }" var="t">
										<c:if test="${t.tel !=null }">
											${t.tel }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										邮件地址：
										<c:forEach items="${c.mailSet }" var="m">
										<c:if test="${m.mail !=null }">
											${m.mail }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										网址：
										<c:forEach items="${c.websiteSet }" var="w">
										<a href="${w.website }">${w.website }</a>&nbsp;
									</c:forEach>
								</td>
							</tr> 
							</c:if>
							<c:if test="${c.view.split(',')[0]=='use'&&c.user.id==sessionScope.user.id&&c.enable  }">
							<tr style="border-bottom:1px solid grey">
								<td width="60px">
									<a href="deletecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/26.png"/></a>
									||
									<a href="updatecontacts.action?id=${c.id }"><img src="<%=basePath %>/bootstrap/img/27.png"/></a>
								</td>
							<td width="30px">
									<c:if test="${c.name!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/18.png"/></span>
									</c:if>
									<c:if test="${c.name==null&&c.companyname!=null }">
										<span class="manpic"><img src="<%=basePath %>/bootstrap/img/25.png"/></span>
									</c:if>
								</td>
								<!--根据不同的情况显示不同-->
								<td width="50%">
										<a href="addcontactsnote.action?id=${c.id }">${c.name }</a><br/>
									公司名称：<a href="addcontactsnote.action?id=${c.id }">${c.companyname }</a><br/>
										联系人电话：
										<c:forEach items="${c.telSet }" var="t">
										<c:if test="${t.tel !=null }">
											${t.tel }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										邮件地址：
										<c:forEach items="${c.mailSet }" var="m">
										<c:if test="${m.mail !=null }">
											${m.mail }&nbsp;
										</c:if>
									</c:forEach>
									<br/>
										网址：
										<c:forEach items="${c.websiteSet }" var="w">
										<a href="${w.website }">${w.website }</a>&nbsp;
									</c:forEach>
								</td>
							</tr>
							</c:if>
					</c:forEach>
					<tr>
								<td></td>
								<td></td>
								<td>
									<c:choose>
							    		<c:when test="${pager.nowpagenum == 1 }">
							    			上一页
							    		</c:when>
							    		<c:when test="${pager.nowpagenum !=1 }">
							    			<a href="contacts.action?p=${pager.nowpagenum-1 }">上一页</a>
							    		</c:when>
							    	</c:choose>
							    	<c:choose>
							    		<c:when test="${pager.nowpagenum != pager.totalpages }">
							    			<a href="contacts.action?p=${pager.nowpagenum+1 }">下一页</a>
							    		</c:when>
							    		<c:otherwise>
							    			下一页
							    		</c:otherwise>
							    	</c:choose>
								</td>
							</tr>
						</table> 
					</div>
				</div>
			</div>
		<div class="span3" style="background-color: #F0F5F8;border: 1px solid #DADEE5;width:170px;height:300px;padding-top:20px;margin-left:25px;color:white;">
				<a class="btn btn-info" href="addcontacts.action" >添加新联系人</a><br/>
				<br/>
				<a class="btn btn-info" href="addcompany.action" >添加新公司</a><br/><br/>
				<a href="import.action" style="color:white">从CSV导入联系人</a><br/>
				<div style="color:red;width:170px;height:60px;margin-top:5px;">
			 		请把要导入的内容按照c:/contacts.xls文件中，
			 		格式不能改动。
			 	</div>
				<a href="export.action" style="color:white">把联系人导出到CSV文件(路径：c:/a.xls)</a><br/>
				<a href="example.action" style="color:white">模板(路径：c:/contacts.xls)</a>
				<c:if test="${param.code=='1007' }">
			 	<div style="color:red;width:100px;height:20px;margin-top:10px;">
			 		操作成功
			 	</div>
			</c:if>
				<c:if test="${param.code=='1006' }">
			 	<div style="color:red;width:100px;height:20px;margin-top:10px;">
			 		操作失败
			 	</div>
			</c:if>
			</div>
		  </div>
		</div>
		<script type="text/javascript">
			$("#xx").click(function(){
				$("#ux").hide();
			});
			$("#gxx").click(function(){
				$("#gx").hide();
			});
		</script>
</body>
</html>